import { notification, message } from 'antd';
import cloneDeep from 'lodash/cloneDeep';
import _map from 'lodash/map';
import _uniq from 'lodash/uniq';
import _pull from 'lodash/pull';
import { sendHtmlWithAtc } from '../../../services/mail_service';

export default {
  namespace: 'mail',
  state: {
    codes: [],
  },

  effects: {
    *SendHtmlWithAtc({ payload, callback }, { call, put }) {
      const response = yield call(sendHtmlWithAtc, payload);
      if (typeof response === 'undefined') {
        notification.error({
          message: typeof response.message !== 'undefined' ? response.message : '请求错误',
        });
      } else if (response.code === 1) {
        message.success('发送成功');
        if (callback) callback(response);
      } else {
        message.success('发送失败');
      }
    },
  },

  reducers: {},
};
